/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package researchgrants.parts.LoggedData.panels;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.event.ChangeEvent;

/**
 *
 * @author DOStudent1
 */
public class LoggedDataPanelsBoolean extends LoggedDataPanels implements ActionListener {

    @Override
    public Component getViewComponent() {
        validateDataToDisplay();
        JCheckBox chkViewData=new JCheckBox();
        chkViewData.setSelected(Boolean.valueOf(getData().value()));
        chkViewData.setEnabled(false);
        return(chkViewData);
    }

    JCheckBox fldEditBox;

    @Override
    public Component getEditComponent() {
        fldEditBox=new JCheckBox();
        fldEditBox.addActionListener(this);
        if (hasDataInitialized()) {
            fldEditBox.setSelected(Boolean.valueOf(getData().value()));
        }
        return(fldEditBox);
    }

    @Override
    public String getEdittedValue() {
        return(Boolean.toString(fldEditBox.isSelected()));
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        ChangeEvent eNew=new ChangeEvent(e.getSource());
        notifyAllChangeListeners(eNew);
    }

    @Override
    public boolean isEmpty() {
        return(false);
    }
    
    @Override
    public boolean isValid() {
        return(true);
    }


}
